package senpec.qc.harmony.person.examPaper;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import senpec.qc.harmony.base.exception.NoResultException;
import senpec.qc.harmony.base.mybatisplus.IBaseServiceImpl;
import senpec.qc.harmony.base.mybatisplus.Result;

import java.util.List;

@Service
@Slf4j
@RequiredArgsConstructor
public class ExamPaperServiceImpl extends IBaseServiceImpl<ExamPaperMapper, ExamPaper> implements ExamPaperService {
    private final ExamPaperMapper examPaperMapper;

    @Override
    public Result<ExamPaper> getById(Long id) {
        ExamPaper examPaper = examPaperMapper.selectById(id);
        if (examPaper == null) {
            throw new NoResultException("未找到该数据");
        } else {
            return Result.ok(examPaper);
        }
    }

    @Override
    public Result<List<ExamPaper>> getListByConditions(ExamPaper conditions) {
        List<ExamPaper> certifications = examPaperMapper.selectList(null);
        return Result.ok(certifications);
    }

    @Override
    public Result<ExamPaper> insertOne(ExamPaper entity) {
        examPaperMapper.insert(entity);
        return Result.ok(entity);
    }

}